<template>
  <div class="card-list">
    <div class="card-item" v-for="item in cardList" :key="item.id">
      <router-link to="/GoodsDetails">
        <img :src="item.imgUrl" alt="" />
        <h4>{{ item.title }}</h4>
        <p class="card-brand">{{ item.name }}</p>
        <p>
          <span>￥{{ item.price.toFixed(2) }}</span>
          <del v-if="item.oldPrice">￥{{ item.oldPrice.toFixed(2) }}</del>
        </p>
      </router-link>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    cardList: {
      type: Array,
      default: () => []
    }
  }
}
</script>

<style lang="less" scoped>
.card-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  color: #333;
  .card-item {
    width: 48%;
    margin-bottom: 0.2rem;
    .card-brand {
      color: #666;
      font-size: 0.24rem;
      margin: 0.12rem 0 0.2rem;
    }
    img {
      width: 100%;
    }
    span {
      color: #f20;
    }
    del {
      color: #999;
      font-size: 0.22rem;
      margin-left: 0.2rem;
    }
  }
}
</style>
